

import vesion2.main.ControlPanel;
import vesion2.main.GamePanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class GameStart extends JFrame {
    public GameStart(){
       GamePanel gPanel=new GamePanel();
       ControlPanel cPanel=new ControlPanel();
       gPanel.setSize(900,700);
       gPanel.requestFocus();
       cPanel.setLayout(null);
       cPanel.setSize(300,700);
       cPanel.setLocation(900,0);
       cPanel.setPanel(gPanel);
       cPanel.setJFrame(this);
       this.add(cPanel);
       this.add(gPanel);
       this.setSize(1218, 747);
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       this.setLocationRelativeTo(null);
       this.setResizable(false);
       this.setLayout(null);
       this.addKeyListener(gPanel);
       this.setFocusable(true);
       this.setVisible(true);
       this.addWindowListener(new WindowListener() {
          @Override
          public void windowOpened(WindowEvent e) {

          }

          @Override
          public void windowClosing(WindowEvent e) {
             gPanel.saveGame();
             cPanel.closeMusic();
             System.exit(0);
          }

          @Override
          public void windowClosed(WindowEvent e) {

          }

          @Override
          public void windowIconified(WindowEvent e) {

          }

          @Override
          public void windowDeiconified(WindowEvent e) {

          }

          @Override
          public void windowActivated(WindowEvent e) {

          }

          @Override
          public void windowDeactivated(WindowEvent e) {

          }
       });
   }
    public static void main(String[] args) {
        GameStart gameStart = new GameStart();
    }
}
